package dmp.tags


import org.apache.spark.broadcast.Broadcast
import org.apache.spark.sql.Row

/**
  * author:CN.CDG
  * Date:2019/2/16
  * Time:11:09
  * App名称标签
  **/
object AppTags extends Tags {
  override def mkTags(args: Any*): List[(String, Int)] = {
    //声明加一个List集合用于返回
    var list=List[(String,Int)]()
    //解析参数
    val row: Row = args(0).asInstanceOf[Row]
    //解析第二个参数
    val broadcastData: Broadcast[Map[String, String]] = args(1).asInstanceOf[Broadcast[Map[String,String]]]
    //获取appname以及appid
    val appname: String = row.getAs[String]("appname")
    val appid = row.getAs[String]("appid")
//判断appname和 appid 是否为空
    if(!"".equals(appname)){
      list:+=("APP"+appname,1)
    }else if(!"".equals(appid)){
      list:+=("APP"+broadcastData.value.getOrElse(appid,appid),1)
    }
list
  }
}
